//
//  EditContactViewController.m
//  DaMaoMall
//
//  Created by DaMaoPC on 16/8/8.
//  Copyright © 2016年 daMao-wally. All rights reserved.
//

#import "EditContactViewController.h"
#import "EditContactTableView.h"
#import "EditManager.h"
#import "DMPopView.h"
@interface EditContactViewController ()

@property (nonatomic, strong)EditContactTableView *editTableView;
@property (nonatomic, strong)UIButton *saveBtn;
@property (nonatomic, assign)BOOL isSvae;
@end

@implementation EditContactViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _isSvae = NO;
    [self setUpConfigure];
    [self setUpCustomView];
}
- (void)setUpCustomView {
    [self.view addSubview:self.editTableView];
    
    //保存
    UIButton *saveBtn = [UIFactory makeButton:@"保存" font:18.0f backColor:nil target:self action:@selector(saveData)];
    [saveBtn setBackgroundImage:GetImage(@"btn-dl") forState:UIControlStateNormal];
    [self.view addSubview:saveBtn];
    
    saveBtn.sd_layout.leftSpaceToView(self.view,10).bottomSpaceToView(self.view,10).rightSpaceToView(self.view,10).heightIs(40);
    self.saveBtn = saveBtn;
}
- (void)saveData {
    NSLog(@"%@ %@ %@",[EditManager shareInstance].contantStr,[EditManager shareInstance].phoneStr,[EditManager shareInstance].type);

    _isSvae = YES;
    [self.navigationController popViewControllerAnimated:YES];

}
- (void)backPrePage {
    if(!_isSvae){
        DMPopView *popView = [[DMPopView alloc] initWithItems:@[@"您还未保存，是否确认退出"] type:DMPopViewStyleMsg];
        [popView show];
        
        [popView didSelectItem:^(NSInteger index) {
            [popView dismiss];
            if(index == 1){
                [self.navigationController popViewControllerAnimated:YES];
            }
        }];
        NSLog(@"未保存");
    }
    
    
}
- (EditContactTableView *)editTableView {
    if(_editTableView == nil) {
        _editTableView = [[EditContactTableView alloc] init];
        _editTableView.backgroundColor = UIColorFromRGB(0xefefef);
        [HideExtraCellLine setExtraCellLineHidden:_editTableView];
        [HideExtraCellLine normalTableview:_editTableView];
    }
    return _editTableView;
}
- (void)setUpConfigure {
    self.titleLabel.text = @"编辑联系方式";
    self.view.backgroundColor  =UIColorFromRGB(0xefefef);
}


@end
